import 'package:get/get.dart';
import 'package:star_author/utils/http/http_util.dart';

class GenerateImageUtil {
  static const String api_url =
      "https://huiliu-mp-1gj64kbz7bc6cf7f-1306825719.ap-shanghai.app.tcloudbase.com/html2image";

  /// 1 竞拍详情 2商品详情
  //生成图片
  static Future<String> generate(int shareType, String url, price) async {
    String image_url = "";
    String template = "evaluation-cover";
    Map slot = {
      "status": "竞拍中",
      "src": url,
    };
    if (shareType == 2) {
      template = "product-cover";
      slot = {
        "price": price,
        "src": url,
      };
    }
    await HttpUtil.commonRequest(
      Get.context!,
      api_url,
      isLoading: false,
      method: HttpUtil.MethodPost,
      data: {
        "template": template,
        "slot": slot,
        "scale": 1,
      },
      isErrorToast: false,
      isCatchErrorLogin: false,
    ).then((value) {
      image_url = value.data;
    });
    return image_url;
  }
}
